{% extends 'admin/common/base.html' %}
{% block body %}
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dict-edit">
			<input id="id" name="id"  type="hidden" value="{{d.id}}" />
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">字典名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="name" id="name" required value="{{d.name}}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">字典类型：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="dict_type" id="dict_type" required value="{{d.dict_type}}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="radio-box">
						<input type="radio" id="6" name="status" value="0" {% if d.status == 0 %}checked="checked" {%endif%}>
						<label for="6">正常</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="7" name="status" value="1" {% if d.status == 1 %}checked="checked" {%endif%}>
						<label for="7">停用</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control">{{d.remark}}</textarea>
				</div>
			</div>
		</form>
	</div>
</body>
{% endblock %}
{% block js %}
{{ super() }}
<script type="text/javascript">

	$("#form-dict-edit").validate({
		onkeyup: false,
		rules:{
			dictType:{
				minlength: 5,
				remote: {
					url: "{{url_for('admin.sys.dict_type.check_dict_type_unique')}}",
					type: "post",
					dataType: "json",
					data: {
						id : function() {
							return $("#id").val();
						},
						dict_type : function() {
							return $.common.trim($("#dict_type").val());
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
		},
		messages: {
			"dict_type": {
				remote: "该字典类型已经存在"
			}
		},
		focusCleanup: true
	});
	
	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save("{{url_for('admin.sys.dict_type.edit')}}", $('#form-dict-edit').serialize());
		}
	}
</script>
{% endblock %}
